'use strict';
/**
 * 菜单表
 */
module.exports = app => {
  const { STRING, UUID, NOW, DATE, UUIDV4, INTEGER } = app.Sequelize;
  const SMenu = app.model.define('SMenu', {
    id: {
      type: UUID,
      primaryKey: true,
      allowNull: false,
      defaultValue: UUIDV4,
      comment: '菜单/按钮 id'
    },
    type: {
      type: INTEGER,
      allowNull: false,
      comment: '类型: 1 菜单，2 按钮'
    },
    title: {
      type: STRING(72),
      allowNull: false,
      comment: '菜单/按钮 名称'
    },
    parentId: {
      type: STRING(36),
      field: 'parent_id',
      comment: '子菜单/按钮的父id',
    },
    url: {
      type: STRING(255),
      comment: '菜单路径，按钮没有'
    },
    order: {
      type: INTEGER,
      comment: '排序'
    },
    permission: {
      type: STRING(255),
      comment: '授权标识(如：sys:user:create)'
    },
    status: {
      type: INTEGER,
      comment: '启用1，禁用0'
    },
    remark: {
      type: STRING(255),
      comment: '备注'
    },
    icon: {
      type: STRING(255),
      field: 'remark',
      comment: '菜单icon'
    },
    createDate: {
      type: DATE,
      defaultValue: NOW,
      field: 'create_date',
      comment: '创建时间'
    },
    updateDate: {
      type: DATE,
      defaultValue: NOW,
      field: 'update_date',
      comment: '更新时间'
    }
  }, {
    // 去除createAt，updateAt
    timestamps: false,
    // 实例对应的表名
    tableName: 's_menu',
    // 将createdAt对应到数据库的created_at字段
    createdAt: 'create_date',
    // 将updatedAt对应到数据库的updated_at字段
    updatedAt: 'updated_date'
  });

  return SMenu;
};